package com.biz.primus.ms.commodity.trans.searchRecommendword;

import com.biz.primus.commodity.vo.backend.searchRecommendWord.SearchRecommendWordVo;
import com.biz.primus.ms.commodity.dao.ro.SearchRecommendWordRo;
import com.google.common.base.Function;

import java.text.DateFormat;
import java.text.SimpleDateFormat;

/**
 * Po --> Vo
 * @author huiwu.heng
 * @date 2017年2月9日
 */
public class SearchRecommendWordRo2SearchRecommendWordVo implements Function<SearchRecommendWordRo, SearchRecommendWordVo> {

	@Override
	public SearchRecommendWordVo apply(SearchRecommendWordRo input) {
		SearchRecommendWordVo resp = new SearchRecommendWordVo();
		resp.setWordId(String.valueOf(input.getId()));
		resp.setIdx(input.getIdx());
		resp.setNote(input.getNote());
		resp.setSearchName(input.getSearchName());
		if(input.getCreateTimestamp() != null){
			resp.setCreateTime(DATE_FORMAT.format(input.getCreateTimestamp()));
		}
		if(input.getUpdateTimestamp() != null){
			resp.setUpdateTime(DATE_FORMAT.format(input.getUpdateTimestamp()));
		}
		return resp;
	}

	private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
}
